/*
 * Widget.cpp
 */

#include "Widget.h"

Widget* manage(Widget* wid)
{
	wid->setManaged();
	return wid;
}

Widget::Widget()
{
	this->managed = false;
	this->isShown = false;
	this->enabled = true;
}

Widget::Widget(Sint16 posX, Sint16 posY, Uint16 w, Uint16 h)
{
	this->widgetArea.x = posX;
	this->widgetArea.y = posY;
	this->widgetArea.w = w;
	this->widgetArea.h = h;
	this->managed = false;
	this->isShown = false;
	this->enabled = true;
}

Widget::~Widget() {}

bool Widget::isManaged() const
{
	return managed;
}

void Widget::setManaged()
{
	managed = true;
}

bool Widget::mustBeShown() const
{
	return this->isShown;
}

void Widget::setShow(bool showProp)
{
	this->isShown = showProp;
}

bool Widget::isEnabled() const
{
	return this->enabled;
}

void Widget::setEnabled(bool value)
{
	this->enabled = value;
}

bool Widget::ocurredInside(Sint16 posX, Sint16 posY)
{
	if( ( posX >= getXCoord() ) && ( posX <= (getXCoord() + getWidth()) )
		&&  ( posY >= getYCoord() ) && ( posY <= (getYCoord() + getHeight()) ) )
        return true;
	return false;
}

Sint16 Widget::getXCoord() const
{
    return this->widgetArea.x;
}

Sint16 Widget::getYCoord() const
{
    return this->widgetArea.y;
}

Uint16 Widget::getHeight() const
{
    return this->widgetArea.h;
}

bool Widget::getManaged() const
{
    return managed;
}

Uint16 Widget::getWidth() const
{
    return this->widgetArea.w;
}

void Widget::setXCoord(Sint16 xCoord)
{
    this->widgetArea.x = xCoord;
}

void Widget::setYCoord(Sint16 yCoord)
{
    this->widgetArea.y = yCoord;
}

void Widget::setHeight(Uint16 height)
{
    this->widgetArea.h = height;
}

void Widget::setWidth(Uint16 width)
{
    this->widgetArea.w = width;
}

const SDL_Rect& Widget::getWidgetArea() const
{
	return this->widgetArea;
}
